package com.seeqool.v1.dataviews;

import java.util.ArrayList;

import org.jfree.data.general.Dataset;
import org.jfree.data.general.DatasetChangeEvent;
import org.jfree.data.general.DatasetChangeListener;
import org.jfree.data.general.DatasetGroup;

public class BaseView implements Dataset {

	private DatasetGroup dataGroup = null;
	private ArrayList<DatasetChangeListener> changeListeners = new ArrayList<DatasetChangeListener>();

	public void addChangeListener(DatasetChangeListener listener) {
		if (!changeListeners.contains(listener))
			changeListeners.add(listener);
	}

	public void removeChangeListener(DatasetChangeListener listener) {
		changeListeners.remove(listener);
	}

	public DatasetGroup getGroup() {
		return dataGroup;
	}

	public void setGroup(DatasetGroup group) {
		dataGroup = group;
	}
	
	public void reportChange() {
		DatasetChangeEvent event = new DatasetChangeEvent(this, this);
		for (DatasetChangeListener listener: changeListeners)
			listener.datasetChanged(event);
	}
}
